/*
Package middlewares
@Author   : Uyynot
@Email    : uyynot@qq.com
@Time     : 2024/5/15 17:40
@File     : force_ua.go
@Project  : gohub
@Desc     :
*/
package middlewares

import (
	"errors"
	"github.com/gin-gonic/gin"
	"gohub/pkg/response"
)

func ForceUA() gin.HandlerFunc {
	return func(c *gin.Context) {
		//获取user-agent头信息
		if len(c.Request.Header["User-Agent"]) == 0 {
			response.BadRequest(c, errors.New("User-Agent不能为空"), "请求必须携带User-Agent信息")
			return
		}
		c.Next()
	}
}
